package com.gmd.actionform;
import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LoginForm extends ActionForm{
 
	private static final long serialVersionUID = 1L;

	private String usu="";
	private String pas="";
	
	public String getUsu() {
		return usu;
	}
	public void setUsu(String usu) {
		this.usu = usu;
	}
	public String getPas() {
		return pas;
	}
	public void setPas(String pas) {
		this.pas = pas;
	}
	
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		try {
			request.setCharacterEncoding("UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		this.usu="";
		this.pas="";
	}
	
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errores= new ActionErrors();
	
		if(usu==null || usu.length()<=0){
			errores.add("usu", new ActionMessage("error.usuario"));
		}if(pas==null || pas.length()<=0){
			errores.add("pas", new ActionMessage("error.clave"));
		}
		
		
	return errores;
	}
	
	
	
}
